@cyphra/graphql 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/index.js +38 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { RemoteJWKSetOptions, JWTVerifyOptions } from 'jose';
|
|
|
8
8
|
* The mapping from `@neo4j/graphql` v7 type definitions to Cyphra, in one place.
|
|
9
9
|
*
|
|
10
10
|
* Each GraphQL scalar, type-level directive and field-level directive has one entry here. When
|
|
11
|
-
* Cyphra gains a feature
|
|
12
|
-
*
|
|
11
|
+
* Cyphra gains a feature, supporting it in the importer means changing that entry: the converter
|
|
12
|
+
* in `convert.ts` only walks the SDL and applies these rules.
|
|
13
13
|
*
|
|
14
14
|
* Semantics follow `@neo4j/graphql` 7.x (checked against 7.6.8):
|
|
15
15
|
* - only object types with `@node` are nodes; `@node(labels)` sets the Neo4j labels;
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
|
|
33
33
|
// src/import/mappings.ts
|
|
34
34
|
import { Kind, valueFromASTUntyped } from "graphql";
|
|
35
|
-
|
|
35
|
+
import { isValidTemporalText } from "@cyphra/schema";
|
|
36
36
|
var SCALARS = {
|
|
37
37
|
ID: { type: "String" },
|
|
38
38
|
String: { type: "String" },
|
|
@@ -42,12 +42,13 @@ var SCALARS = {
|
|
|
42
42
|
DateTime: { type: "DateTime" },
|
|
43
43
|
Date: { type: "Date" },
|
|
44
44
|
BigInt: { type: "BigInt" },
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
// Same Neo4j types: `Time` keeps its offset, `Point` is WGS-84, `CartesianPoint` Cartesian.
|
|
46
|
+
Time: { type: "Time" },
|
|
47
|
+
LocalTime: { type: "LocalTime" },
|
|
48
|
+
LocalDateTime: { type: "LocalDateTime" },
|
|
49
|
+
Duration: { type: "Duration" },
|
|
50
|
+
Point: { type: "Point" },
|
|
51
|
+
CartesianPoint: { type: "CartesianPoint" }
|
|
51
52
|
};
|
|
52
53
|
function enumField(name) {
|
|
53
54
|
return { type: "Enum", enum: name };
|
|
@@ -121,6 +122,11 @@ function defaultFromValue(v, ctx) {
|
|
|
121
122
|
case "DateTime":
|
|
122
123
|
case "Date":
|
|
123
124
|
return { error: `Cyphra only supports @default(now()) on ${ctx.type} fields` };
|
|
125
|
+
case "Time":
|
|
126
|
+
case "LocalTime":
|
|
127
|
+
case "LocalDateTime":
|
|
128
|
+
if (v.kind === Kind.STRING && isValidTemporalText(ctx.type, v.value)) return v.value;
|
|
129
|
+
break;
|
|
124
130
|
}
|
|
125
131
|
return { error: `the default does not match type ${ctx.graphqlType}` };
|
|
126
132
|
}
|
|
@@ -179,9 +185,11 @@ var FIELD_DIRECTIVES = {
|
|
|
179
185
|
kind: "scalar",
|
|
180
186
|
apply: (d, ctx) => {
|
|
181
187
|
const ops = enumListArg(d, "operations") ?? ["CREATE", "UPDATE"];
|
|
182
|
-
if (ctx.type !== "DateTime" || ctx.list) {
|
|
188
|
+
if (ctx.type !== "DateTime" && ctx.type !== "Time" || ctx.list) {
|
|
183
189
|
return {
|
|
184
|
-
issues: [
|
|
190
|
+
issues: [
|
|
191
|
+
issue("unsupported", "@timestamp", "@timestamp is only converted on DateTime and Time")
|
|
192
|
+
]
|
|
185
193
|
};
|
|
186
194
|
}
|
|
187
195
|
if (!ops.includes("CREATE")) {
|
|
@@ -869,6 +877,12 @@ var CYPHRA_TYPE_NAMES = /* @__PURE__ */ new Set([
|
|
|
869
877
|
"Date",
|
|
870
878
|
"BigInt",
|
|
871
879
|
"Json",
|
|
880
|
+
"LocalDateTime",
|
|
881
|
+
"LocalTime",
|
|
882
|
+
"Time",
|
|
883
|
+
"Duration",
|
|
884
|
+
"Point",
|
|
885
|
+
"CartesianPoint",
|
|
872
886
|
"Vector"
|
|
873
887
|
]);
|
|
874
888
|
function enumMappings(types, nodeNames, report) {
|
|
@@ -4768,14 +4782,27 @@ function createExecutors(opts) {
|
|
|
4768
4782
|
const rows = async (tx, cypher, params) => (await tx.run(cypher, params)).records.map((r) => r.get("this"));
|
|
4769
4783
|
if (opts.client) {
|
|
4770
4784
|
const client = opts.client;
|
|
4785
|
+
const clientRows = async (tx, cypher, params, op) => (await client.runCompiledTx(
|
|
4786
|
+
tx,
|
|
4787
|
+
{ text: cypher, params },
|
|
4788
|
+
{ operation: op, transaction: false }
|
|
4789
|
+
)).records.map((r) => r.get("this"));
|
|
4771
4790
|
return {
|
|
4772
4791
|
read: async (cypher, params) => {
|
|
4773
4792
|
log(cypher, params);
|
|
4774
|
-
return client.
|
|
4793
|
+
return client.instrumentation.operation(
|
|
4794
|
+
{ operation: "graphql.read" },
|
|
4795
|
+
() => client.withReadTransaction((tx) => clientRows(tx, cypher, params, "graphql.read"))
|
|
4796
|
+
);
|
|
4775
4797
|
},
|
|
4776
4798
|
write: async (cypher, params, consume) => {
|
|
4777
4799
|
log(cypher, params);
|
|
4778
|
-
return client.
|
|
4800
|
+
return client.instrumentation.operation(
|
|
4801
|
+
{ operation: "graphql.write" },
|
|
4802
|
+
() => client.withWriteTransaction(
|
|
4803
|
+
async (tx) => consume(await clientRows(tx, cypher, params, "graphql.write"))
|
|
4804
|
+
)
|
|
4805
|
+
);
|
|
4779
4806
|
}
|
|
4780
4807
|
};
|
|
4781
4808
|
}
|